package com.mpsc.spring.demo.sevice.impl;


import com.mpsc.spring.demo.event.SendMsgEvent;
import com.mpsc.spring.demo.sevice.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import java.util.concurrent.ExecutorService;

@Service
public class EventServiceImpl implements EventService {

    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    private ExecutorService executorService;

    @Override
    public void createEvent() {
        System.out.println(Thread.currentThread().getName());
        applicationContext.publishEvent(new SendMsgEvent("Hello,World!","Mr.Lensen", "I Love U"));
        //executorService.execute(()-> System.out.println("异步打印"));
    }
}
